package com.zjcloud.jwgl.domain;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zjcloud.common.annotation.Excel;
import com.zjcloud.common.core.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.*;
import java.util.Date;

/**
 * 约束模板关联对象 ac_template_constraint_rel
 * 
 * @author zjcloud
 * @date 2024-01-01
 */
public class AcTemplateConstraintRel extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    private Long id;

    /** 模板ID */
    @Excel(name = "模板ID")
    private Long templateId;

    /** 约束类型ID */
    @Excel(name = "约束类型ID")
    private Long constraintTypeId;

    /** 权重(0-100) */
    @Excel(name = "权重")
    private Integer weight;

    /** 优先级(1-10，数字越小优先级越高) */
    @Excel(name = "优先级")
    private Integer priority;

    /** 是否启用(0-否 1-是) */
    @Excel(name = "是否启用", readConverterExp = "0=否,1=是")
    private String enabled;

    /** 配置JSON */
    @Excel(name = "配置JSON")
    private String configJson;

    /** 排序号 */
    @Excel(name = "排序号")
    private Integer sortOrder;

    /** 关联的约束模板（非数据库字段） */
    private AcScheduleConstraintTemplate template;

    /** 关联的约束类型（非数据库字段） */
    private AcConstraintType constraintType;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setTemplateId(Long templateId) 
    {
        this.templateId = templateId;
    }

    public Long getTemplateId() 
    {
        return templateId;
    }
    public void setConstraintTypeId(Long constraintTypeId) 
    {
        this.constraintTypeId = constraintTypeId;
    }

    public Long getConstraintTypeId() 
    {
        return constraintTypeId;
    }
    public void setWeight(Integer weight) 
    {
        this.weight = weight;
    }

    public Integer getWeight() 
    {
        return weight;
    }
    public void setPriority(Integer priority) 
    {
        this.priority = priority;
    }

    public Integer getPriority() 
    {
        return priority;
    }
    public void setEnabled(String enabled) 
    {
        this.enabled = enabled;
    }

    public String getEnabled() 
    {
        return enabled;
    }
    public void setConfigJson(String configJson) 
    {
        this.configJson = configJson;
    }

    public String getConfigJson() 
    {
        return configJson;
    }
    public void setSortOrder(Integer sortOrder) 
    {
        this.sortOrder = sortOrder;
    }

    public Integer getSortOrder() 
    {
        return sortOrder;
    }

    public AcScheduleConstraintTemplate getTemplate() 
    {
        return template;
    }

    public void setTemplate(AcScheduleConstraintTemplate template) 
    {
        this.template = template;
    }

    public AcConstraintType getConstraintType() 
    {
        return constraintType;
    }

    public void setConstraintType(AcConstraintType constraintType) 
    {
        this.constraintType = constraintType;
    }

    /**
     * 判断是否启用
     */
    public boolean isEnabled() {
        return "1".equals(this.enabled);
    }

    /**
     * 获取权重百分比
     */
    public double getWeightPercentage() {
        return weight != null ? weight / 100.0 : 0.0;
    }

    /**
     * 获取优先级描述
     */
    public String getPriorityDesc() {
        if (priority == null) {
            return "未设置";
        }
        if (priority <= 3) {
            return "高";
        } else if (priority <= 6) {
            return "中";
        } else {
            return "低";
        }
    }

    /**
     * 获取约束类型名称
     */
    public String getConstraintTypeName() {
        return constraintType != null ? constraintType.getTypeName() : "";
    }

    /**
     * 获取约束类型编码
     */
    public String getConstraintTypeCode() {
        return constraintType != null ? constraintType.getTypeCode() : "";
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("templateId", getTemplateId())
            .append("constraintTypeId", getConstraintTypeId())
            .append("weight", getWeight())
            .append("priority", getPriority())
            .append("enabled", getEnabled())
            .append("configJson", getConfigJson())
            .append("sortOrder", getSortOrder())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("remark", getRemark())
            .toString();
    }
}